#ifndef DW_BASE_POOL_INL
#	define DW_BASE_POOL_INL

namespace dw {
	namespace base {

template< typename T, uint32 Size >
Pool< T, Size >::Pool()
:	m_size(Size)
,	m_pool(NULL)
{ 
	m_pool = new T[Size];
	for (dw::uint32 i = 0; i < m_size; ++i)
		m_stack.push(i);
}

template< typename T, uint32 Size >
inline T& Pool< T, Size >::operator [] (uint32 i)
{
	if (i < m_size)
		return m_pool[i];
}

template< typename T, uint32 Size >
inline dw::uint32 Pool< T, Size >::insert(const T& elt)
{
	dw::uint32 index;

	if (m_stack.empty())
		return -1;
	else
	{
		index = m_stack.top();
		*m_pool[index] = elt;
		m_stack.pop();
	}

	return index;
}

template< typename T, uint32 Size >
inline void Pool< T, Size >::remove(uint32 i)
{
	if (i < m_size)
		m_stack.push(i);
}

template< typename T, uint32 Size >
inline void Pool< T, Size >::flush()
{
	for (dw::uint32 i = 0; i < m_size; ++i)
		m_stack.push(i);
}

	} // namespace base
} // namespace dw

#endif // !DW_BASE_POOL_INL
